import axios from "axios";
const requers = axios.create({
  baseURL: import.meta.env.VITE_APP_BASE_API,
});

// 用户列表
export function userList() {
  return requers.post("user/list/1/2", {
    name: "admin",
    page: 1,
    size: 5,
  });
}

// 优惠券删除
export function discountDel(id = "2") {
  return requers.get("discount/remove/" + id);
}

// 优惠券id查询
export function discountQuery() {
  return requers.get("discount/get/1");
}

// 优惠券新增
export function discountAdd(
  discountName = "1",
  type = "1",
  faceValue = "1",
  fullDecrement = "1",
  PickableQuantity = "1",
  NumberOfIssues = "1",
  RemainingQuantity = "1",
  ScopeOfAction = "1",
  state = "1",
  effectiveDate = "1",
  expirationDate = "1",
  userId = "1"
) {
  return requers.post("discount/add", {
    discountName, //优惠卷名字
    type, //类型
    faceValue, //面值
    fullDecrement, //消费满减
    PickableQuantity, //可领取数量
    NumberOfIssues, //发行数量
    RemainingQuantity, //剩余数量
    ScopeOfAction, //作用范围
    state, //状态
    effectiveDate, //发行时间
    expirationDate, //结束时间
    userId, //用户id
  });
}

// 优惠券查询
export function discountList(kw = "") {
  return requers.post("discount/list", {
    cp: "1",
    ls: "100",
    kw,
  });
}

// 分类导航
export function productSave() {
  return requers.post("productList/save", {
    totalName: "感冒药",
    urlImage: "https://t7.baidu.com/it/u=1951548898,3927145&fm=193&f=GIF",
    content: "买感冒药",
  });
}

//登录
export function Login(username, password) {
  return requers.post("emp/login", {
    username,
    password,
  });
}

// 优惠券查询
export function urlImage() {
  return requers.post("details/upload");
}
